package dd.view;

import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;
import javax.swing.border.EmptyBorder;

import dd.control.RequestCreateEventController;
import dd.model.Event;

public class CreateForm extends JFrame {

	JPanel contentPane;
	JTextField eventNameTextField;
	JComboBox typeComboBox;
	JComboBox modeComboBox;
	Event event;
	
	public static final String mode_open = "open";
	public static final String mode_closed = "closed";
	
	public static final String type_rr = "roundRobin";
	public static final String type_async = "asynchronous";
	private JTextField numLinesTextField;
	private JTextField numEdgesTextField;

	/**
	 * Create the frame.
	 */
	public CreateForm(Event event) {
		this.event = event;
		setTitle("CreateEvent Form");
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setBounds(100, 100, 521, 328);
		contentPane = new JPanel();
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		setContentPane(contentPane);
		contentPane.setLayout(null);
		
		JLabel lblMode = new JLabel("Mode");
		lblMode.setBounds(75, 32, 61, 16);
		contentPane.add(lblMode);
		
		modeComboBox = new JComboBox(new Object[] { mode_open, mode_closed });
		modeComboBox.setBounds(229, 28, 189, 27);
		contentPane.add(modeComboBox);
		
		JLabel lblType = new JLabel("Type");
		lblType.setBounds(75, 78, 61, 16);
		contentPane.add(lblType);
		
		typeComboBox = new JComboBox(new Object[] { type_rr, type_async});
		typeComboBox.setBounds(229, 73, 189, 27);
		contentPane.add(typeComboBox);
		
		JButton btnCreate = new JButton("Create");
		btnCreate.setBounds(356, 250, 117, 29);
		contentPane.add(btnCreate);
		
		//Model model = Model.getInstance();
		//Event event=new Event();
		//model.setEvent(event);
		//event = model.getEvent();
		btnCreate.addActionListener(new RequestCreateEventController(this, event));
		
		eventNameTextField = new JTextField();
		eventNameTextField.setBounds(229, 122, 189, 28);
		contentPane.add(eventNameTextField);
		eventNameTextField.setColumns(10);
		
		JLabel lblName = new JLabel("Name");
		lblName.setBounds(75, 128, 44, 16);
		contentPane.add(lblName);
		
		JLabel lblChoices = new JLabel("Maximun number of choices(M)");
		lblChoices.setBounds(10, 171, 198, 14);
		contentPane.add(lblChoices);
		
		JLabel lblMaximunNumberOf = new JLabel("Maximun number of edges(N)");
		lblMaximunNumberOf.setBounds(10, 207, 198, 14);
		contentPane.add(lblMaximunNumberOf);
		
		numLinesTextField = new JTextField();
		numLinesTextField.setBounds(228, 166, 86, 24);
		contentPane.add(numLinesTextField);
		numLinesTextField.setColumns(10);
		
		numEdgesTextField = new JTextField();
		numEdgesTextField.setBounds(228, 205, 86, 24);
		contentPane.add(numEdgesTextField);
		numEdgesTextField.setColumns(10);
	}
	
	public JComboBox getModeComboBox() {
		return modeComboBox;
	}
	
	public JComboBox getTypeComboBox() {
		return typeComboBox;
	}
	
	public JTextField getEventNameTextField() {
		return eventNameTextField;
	}
	
	public JTextField getMTextField() {
		return numLinesTextField;
	}
	
	public JTextField getNTextField() {
		return numEdgesTextField;
	}
}
